package com.huabo.utils;

import com.huabo.key.generator.IdWorker;
import com.huabo.key.generator.ObjectId;

import java.util.UUID;

public class KeyUtils {

	private static final IdWorker ID_WORKER = new IdWorker();

	private KeyUtils() {

	}

	/**
	 * 使用mongodb ObjectId实现
	 * @return
	 */
	public static String getKey() {
		return ObjectId.get().toString();
	}
	
	/**
	 * 32位UUID
	 * @return
	 */
	public static String getUUID(){
		return UUID.randomUUID().toString().trim().replaceAll("-", "");
	}

	/**
	 * 分布式自增长ID
	 * @return
	 */
	public static long getDistributedId() {
		return ID_WORKER.nextId();
	}
}
